<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>
     字典数据
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/css/main.css}" media="all">
    <script type="text/javascript" th:src="@{/lib/loading/okLoading.js}"></script>
    <link rel="stylesheet" th:href="@{/css/bootstrap.css}">
    <!--导入ElementUI样式列表，css样式一般都在页面头部-->
    <link rel="stylesheet" th:href="@{/css/index.css}">
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>数据中心</cite></a>
              <a><cite>字典数据</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" id="app">

    <xblock>
        <button class="layui-btn layui-btn-danger" @click="delAll()"><i class="layui-icon">&#xe640;</i>批量删除</button>
        <button class="layui-btn" @click="admin_add('添加','dictionaryadd.html','1000','600')"><i
                class="layui-icon">&#xe608;</i>添加
        </button>
        <button class="layui-btn" @click="fanhui()"><i
                class="layui-icon">&#xe608;</i>返回
        </button>
<!--    -->
    </xblock>
    <table class="layui-table" id="ches">
        <thead>
        <tr>
            <th>
                字典编码
            </th>
            <th>
                字典标签
            </th>
            <th>
                字典建值
            </th>
            <th>
                字典排序
            </th>
            <th>
                创建时间
            </th>
            <th>
               操作者
            </th>
            <th>
                操作
            </th>
        </tr>
        </thead>
        <tbody id="x-img">
        <tr v-for="(dictionary,index) in dictionaryList">
            <td>
                {{index+1}}
          </td>
            <td>{{dictionary.dictionaryName}}</td>
            <td>{{index}}</td>
            <td>{{index+1}}</td>
            <td>{{dateFormat(dictionary.creationTime)}}</td>
            <td v-if="dictionary.createdBy == 1">张三</td>
            <td v-if="dictionary.createdBy == 2">李四</td>
            <td v-if="dictionary.createdBy == 3">王五</td>
            <td v-if="dictionary.createdBy == 4">雷六</td>
            <td class="td-manage">
                <a title="编辑" href="javascript:;" @click="building_edit('编辑','dictionaryadd.html',dictionary.dictionaryId,'1000','600')"
                   class="ml-5" style="text-decoration:none">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" href="javascript:;" @click="del_one(dictionary.dictionaryId)"
                   style="text-decoration:none">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        </tbody>
    </table>

</div>
<script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
<!--js脚本一般是放在页面尾部-->
<!--Vue js脚本-->
<script th:src="@{/js/vue.js}" charset="utf-8"></script>
<!--引入ElementUI组件库-->
<script th:src="@{/js/index.js}" charset="utf-8"></script>
<!--引入Axios js脚本-->
<script th:src="@{/js/axios.js}" charset="utf-8"></script>
<!--引入时间插件包Momentjs-->
<script th:src="@{/js/moment.min.js}" charset="utf-8"></script>
<script>
    var token='[[${session.estateManager}]]';
    console.log(token)
    var app = new Vue({
        el: "#app",//声明当前Vue在页面的作用域
        data: {
            code: [1,2,3],
            dictionaryList: [],
            dictionary: {
                dictionaryId: "",
                dictionaryName: "",
                dictionaryType: "",
                parentId: "",
                remarks: "",
            },
            total: 10,
            // searchMap: {"startTime": "", "endTime": "", "parentId": "1","dictionaryName":"", "pageNum": 1, "pageSize": 3},
            selectDate: ['', ''],
            pickerOptions: {
                shortcuts: [{
                    text: '最近一周',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近一个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近三个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                        picker.$emit('pick', [start, end]);
                    }
                }]
            }
        },
        methods: {

            fanhui(){
                window.location.href="dictionary.html";
            },

            findById() {
                axios.get("/dictionary/dictionarydata?dictionaryType=" +this.dictionary.dictionaryType).then((res) => {
                    console.log(this.code);
                    console.log(res);
                    this.dictionaryList = res.data.data;
                    console.log(this.dictionaryList)
                });
            },

            //日期格式化方法
            //date 要进行格式的日期 ；format 格式化的样式
            dateFormat(date, format) {
                //默认格式化字符串"YYYY-MM-DD HH:mm:ss"
                if (format == null || format == '') {
                    format = "YYYY-MM-DD HH:mm:ss";
                }
                return moment(date).format(format);
            },


            /*关闭弹出框口*/
            x_admin_close() {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            },

            getQueryString(name) {
                let reg = `(^|&)${name}=([^&]*)(&|$)`
                let r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            }

        },


        created: function () {//Vue生命周期方法，加载页面时会执行该方法
            layui.use(['laydate', 'element', 'laypage', 'layer'], function () {
                $ = layui.jquery;//jquery
                layer = layui.layer;//弹出层
                okLoading.close($);
                layer.ready(function () { //为了layer.ext.js加载完毕再执行
                    layer.photos({
                        photos: '#x-img'
                    });
                });
            });

            //获取父页面传递参数，小区ID
            this.dictionary.dictionaryType = this.getQueryString("dictionaryType");
            //初始页面获取小区列表信息
            this.findById();


        }
    });

    function question_show(argument) {
        layer.msg('可以跳到前台具体问题页面', {icon: 1, time: 1000});
    }
</script>

</body>
</html>